#define _CRT_SECURE_NO_WARNINGS 1

#include "sort.h"

void TestInsertSort()
{
	int a[] = { 3,8,1,0,6,4,7,2,5,9 };
	
	int n = sizeof(a) / sizeof(a[0]);

	PrintArray(a, n);

	InsertSort(a, n);

	PrintArray(a, n);
}

void TestShellSort()
{
	int a[] = { 3,8,1,0,6,4,7,2,5,9 };

	int n = sizeof(a) / sizeof(a[0]);

	PrintArray(a, n);

	ShellSort(a, n);
	
	PrintArray(a, n);
}

void TestOP()
{
	srand((unsigned int)time(0));
	const int N = 100000;
	int* a1 = (int*)malloc(sizeof(int) * N);
	int* a2 = (int*)malloc(sizeof(int) * N);

	for (int i = 0; i < N; ++i)
	{
		a1[i] = rand();
		a2[i] = a1[i];
	}

	int begin1 = clock();
	InsertSort(a1, N);
	int end1 = clock();

	int begin2 = clock();
	ShellSort(a2, N);
	int end2 = clock();


	printf("InsertSort:%d\n", end1 - begin1);
	printf("ShellSort:%d\n", end2 - begin2);

	free(a1);
	free(a2);
}

int main()
{
	//TestInsertSort();
	//TestShellSort();

	TestOP();

	return 0;
}